View Javadoc
1 /*** 2 * Copyright 2003, 2004, 2005. CodeStreet LLC. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 15 package com.codestreet.selector.parser; 16 17 import java.util.HashMap; 18 import java.util.Map; 19 20 /*** 21 * Class to represent a <tt>Double</tt> literal. Immutable. 22 * 23 * @author Jawaid Hakim. 24 */ 25 final class LiteralDouble implements IExpressionNumeric 26 { 27 /*** 28 * Factory. 29 * 30 * @param literal 31 * Literal. 32 * @return Instance. 33 */ 34 public static synchronized LiteralDouble valueOf(final String literal) 35 { 36 LiteralDouble instance = (LiteralDouble) idMap_.get(literal); 37 if (instance == null) 38 { 39 instance = new LiteralDouble(literal); 40 idMap_.put(literal, instance); 41 } 42 return instance; 43 } 44 45 /*** 46 * Ctor. 47 * 48 * @param literal 49 * Double literal. 50 */ 51 private LiteralDouble(final String literal) 52 { 53 literal_ = new NumericValue(Double.valueOf(literal)); 54 } 55 56 public Object eval(final Map identifiers) 57 { 58 return literal_; 59 } 60 61 public Object eval(final IValueProvider provider, final Object corr) 62 { 63 return literal_; 64 } 65 66 public String toString() 67 { 68 return literal_.toString(); 69 } 70 71 private final NumericValue literal_; 72 73 private static Map idMap_ = new HashMap(); 74 }

This page was automatically generated by Maven